import axios from "axios"

const getMyAuthCode = async user => {
  const code = Math.floor(Math.random() * (9999 - 1000)) + 1000
  const res = await axios({
    url: 'http://gyytz.market.alicloudapi.com/sms/smsSend',
    method: 'post',
    params: {
      mobile: user,
      param: `**code**:${code},**minute**:5`,
      smsSignId: process.env.SMSSIGNID,
      templateId: process.env.TEMPLATEID,
    },
    headers: {
      'Authorization': `APPCODE ${process.env.APPCODE}`,
      'Content-Type': 'application/xrlencoded; charset=utf-8-www-form-u'
    }
  })
  return {
    status: res.data.code,
    msg: res.data.msg,
    correctCode: String(code)
  }
}

export {
  getMyAuthCode
}